package com.jse.jakarta;

import java.io.IOException;

import com.jse.Jse;
import com.jse.Log;
import com.jse.web.Ctx;
import com.jse.web.Web;

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class JseServlet extends HttpServlet{

	private static final long serialVersionUID = 1L;
	
	private final static Log log=Log.get("jseservlet");
	
	
	@Override
	public void init(ServletConfig conf) throws ServletException {
		Web.init();
	}

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
//		String url=req.getRequestURI().substring(req.getContextPath().length());
//		System.out.println("url:"+url);
//		String suffix=Fs.suffix(req.getRequestURI());
//		if(url.endsWith("/"))url+="index";//mapping
		req.setCharacterEncoding(Jse.encoding);
		resp.setCharacterEncoding(Jse.encoding);
		Ctx ctx=new Tbl();
		ctx.parse(req, resp);
		Web.service(ctx);
		
//		Tbl tbl=new Tbl(req, resp);
//		if(staticDispatcher!=null&&Web.isStatic(tbl.getPath(),tbl.getSuffix())) {//静态
//			staticDispatcher.forward(req,resp);return;
//		}
//		Action.service(tbl);

	}
	
}
